// $ANTLR 3.3 Nov 30, 2010 12:50:56 SQL.g 2011-04-13 23:11:05

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 219
// Unreachable code detected.
#pragma warning disable 162

using Magic.Framework.OQL.Expressions; 

using System.Collections.Generic;
using Antlr.Runtime;
using Stack = System.Collections.Generic.Stack<object>;
using List = System.Collections.IList;
using ArrayList = System.Collections.Generic.List<object>;


using Antlr.Runtime.Tree;
using RewriteRuleITokenStream = Antlr.Runtime.Tree.RewriteRuleTokenStream;

namespace  Magic.Framework.OQL
{
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.3 Nov 30, 2010 12:50:56")]
[System.CLSCompliant(false)]
public partial class SQLParser : Antlr.Runtime.Parser
{
	internal static readonly string[] tokenNames = new string[] {
		"<invalid>", "<EOR>", "<DOWN>", "<UP>", "Eq", "Neq1", "Neq2", "Le1", "Le2", "Lt", "Ge1", "Ge2", "Gt", "DIV", "PLUS", "MINUS", "MUL", "MOD", "BITAND", "BITNOT", "BITOR", "BITXOR", "LPAREN", "RPAREN", "COLON", "COMMA", "SEMI", "DOT", "SELECT", "FROM", "WHERE", "AND", "OR", "NOT", "NonQuotedIdentifier", "Integer", "Txt", "Whitespace", "DigitChar", "NonQuotedIdentifier_0", "LetterChar", "TextNode", "SelectClause", "SelectStmt", "WhereClause", "Table", "Column", "Predicate", "Group"
	};
	public const int EOF=-1;
	public const int Eq=4;
	public const int Neq1=5;
	public const int Neq2=6;
	public const int Le1=7;
	public const int Le2=8;
	public const int Lt=9;
	public const int Ge1=10;
	public const int Ge2=11;
	public const int Gt=12;
	public const int DIV=13;
	public const int PLUS=14;
	public const int MINUS=15;
	public const int MUL=16;
	public const int MOD=17;
	public const int BITAND=18;
	public const int BITNOT=19;
	public const int BITOR=20;
	public const int BITXOR=21;
	public const int LPAREN=22;
	public const int RPAREN=23;
	public const int COLON=24;
	public const int COMMA=25;
	public const int SEMI=26;
	public const int DOT=27;
	public const int SELECT=28;
	public const int FROM=29;
	public const int WHERE=30;
	public const int AND=31;
	public const int OR=32;
	public const int NOT=33;
	public const int NonQuotedIdentifier=34;
	public const int Integer=35;
	public const int Txt=36;
	public const int Whitespace=37;
	public const int DigitChar=38;
	public const int NonQuotedIdentifier_0=39;
	public const int LetterChar=40;
	public const int TextNode=41;
	public const int SelectClause=42;
	public const int SelectStmt=43;
	public const int WhereClause=44;
	public const int Table=45;
	public const int Column=46;
	public const int Predicate=47;
	public const int Group=48;

	// delegates
	// delegators

	#if ANTLR_DEBUG
		private static readonly bool[] decisionCanBacktrack =
			new bool[]
			{
				false, // invalid decision
				false, false, false, false, false, false, false, false, false, false, 
				false, false, false, false
			};
	#else
		private static readonly bool[] decisionCanBacktrack = new bool[0];
	#endif
	public SQLParser( ITokenStream input )
		: this( input, new RecognizerSharedState() )
	{
	}
	public SQLParser(ITokenStream input, RecognizerSharedState state)
		: base(input, state)
	{
		ITreeAdaptor treeAdaptor = null;
		CreateTreeAdaptor(ref treeAdaptor);
		TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();

		OnCreated();
	}
		
	// Implement this function in your helper file to use a custom tree adaptor
	partial void CreateTreeAdaptor(ref ITreeAdaptor adaptor);

	private ITreeAdaptor adaptor;

	public ITreeAdaptor TreeAdaptor
	{
		get
		{
			return adaptor;
		}
		set
		{
			this.adaptor = value;
		}
	}

	public override string[] TokenNames { get { return SQLParser.tokenNames; } }
	public override string GrammarFileName { get { return "SQL.g"; } }


	partial void OnCreated();
	partial void EnterRule(string ruleName, int ruleIndex);
	partial void LeaveRule(string ruleName, int ruleIndex);

	#region Rules
	public class start_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_start();
	partial void Leave_start();

	// $ANTLR start "start"
	// SQL.g:47:1: start : statements ;
	[GrammarRule("start")]
	public SQLParser.start_return start()
	{
		Enter_start();
		EnterRule("start", 1);
		TraceIn("start", 1);
		SQLParser.start_return retval = new SQLParser.start_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.statements_return statements1 = default(SQLParser.statements_return);


		try { DebugEnterRule(GrammarFileName, "start");
		DebugLocation(47, 18);
		try
		{
			// SQL.g:47:6: ( statements )
			DebugEnterAlt(1);
			// SQL.g:47:8: statements
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(47, 8);
			PushFollow(Follow._statements_in_start306);
			statements1=statements();
			PopFollow();

			adaptor.AddChild(root_0, statements1.Tree);

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("start", 1);
			LeaveRule("start", 1);
			Leave_start();
		}
		DebugLocation(47, 18);
		} finally { DebugExitRule(GrammarFileName, "start"); }
		return retval;

	}
	// $ANTLR end "start"

	public class statements_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_statements();
	partial void Leave_statements();

	// $ANTLR start "statements"
	// SQL.g:48:1: statements : ( statement ( ( SEMI )? ) )* EOF ;
	[GrammarRule("statements")]
	private SQLParser.statements_return statements()
	{
		Enter_statements();
		EnterRule("statements", 2);
		TraceIn("statements", 2);
		SQLParser.statements_return retval = new SQLParser.statements_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken SEMI3=null;
		IToken EOF4=null;
		SQLParser.statement_return statement2 = default(SQLParser.statement_return);

		Expression SEMI3_tree=null;
		Expression EOF4_tree=null;

		try { DebugEnterRule(GrammarFileName, "statements");
		DebugLocation(48, 39);
		try
		{
			// SQL.g:48:11: ( ( statement ( ( SEMI )? ) )* EOF )
			DebugEnterAlt(1);
			// SQL.g:48:13: ( statement ( ( SEMI )? ) )* EOF
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(48, 13);
			// SQL.g:48:13: ( statement ( ( SEMI )? ) )*
			try { DebugEnterSubRule(2);
			while (true)
			{
				int alt2=2;
				try { DebugEnterDecision(2, decisionCanBacktrack[2]);
				int LA2_0 = input.LA(1);

				if ((LA2_0==SELECT))
				{
					alt2=1;
				}


				} finally { DebugExitDecision(2); }
				switch ( alt2 )
				{
				case 1:
					DebugEnterAlt(1);
					// SQL.g:48:14: statement ( ( SEMI )? )
					{
					DebugLocation(48, 14);
					PushFollow(Follow._statement_in_statements315);
					statement2=statement();
					PopFollow();

					adaptor.AddChild(root_0, statement2.Tree);
					DebugLocation(48, 24);
					// SQL.g:48:24: ( ( SEMI )? )
					DebugEnterAlt(1);
					// SQL.g:48:25: ( SEMI )?
					{
					DebugLocation(48, 25);
					// SQL.g:48:25: ( SEMI )?
					int alt1=2;
					try { DebugEnterSubRule(1);
					try { DebugEnterDecision(1, decisionCanBacktrack[1]);
					int LA1_0 = input.LA(1);

					if ((LA1_0==SEMI))
					{
						alt1=1;
					}
					} finally { DebugExitDecision(1); }
					switch (alt1)
					{
					case 1:
						DebugEnterAlt(1);
						// SQL.g:48:25: SEMI
						{
						DebugLocation(48, 25);
						SEMI3=(IToken)Match(input,SEMI,Follow._SEMI_in_statements318); 
						SEMI3_tree = (Expression)adaptor.Create(SEMI3);
						adaptor.AddChild(root_0, SEMI3_tree);


						}
						break;

					}
					} finally { DebugExitSubRule(1); }


					}


					}
					break;

				default:
					goto loop2;
				}
			}

			loop2:
				;

			} finally { DebugExitSubRule(2); }

			DebugLocation(48, 38);
			EOF4=(IToken)Match(input,EOF,Follow._EOF_in_statements325); 

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("statements", 2);
			LeaveRule("statements", 2);
			Leave_statements();
		}
		DebugLocation(48, 39);
		} finally { DebugExitRule(GrammarFileName, "statements"); }
		return retval;

	}
	// $ANTLR end "statements"

	public class statement_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_statement();
	partial void Leave_statement();

	// $ANTLR start "statement"
	// SQL.g:50:1: statement : selectStatement ;
	[GrammarRule("statement")]
	private SQLParser.statement_return statement()
	{
		Enter_statement();
		EnterRule("statement", 3);
		TraceIn("statement", 3);
		SQLParser.statement_return retval = new SQLParser.statement_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.selectStatement_return selectStatement5 = default(SQLParser.selectStatement_return);


		try { DebugEnterRule(GrammarFileName, "statement");
		DebugLocation(50, 1);
		try
		{
			// SQL.g:50:10: ( selectStatement )
			DebugEnterAlt(1);
			// SQL.g:53:2: selectStatement
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(53, 2);
			PushFollow(Follow._selectStatement_in_statement339);
			selectStatement5=selectStatement();
			PopFollow();

			adaptor.AddChild(root_0, selectStatement5.Tree);

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("statement", 3);
			LeaveRule("statement", 3);
			Leave_statement();
		}
		DebugLocation(57, 1);
		} finally { DebugExitRule(GrammarFileName, "statement"); }
		return retval;

	}
	// $ANTLR end "statement"

	public class selectStatement_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_selectStatement();
	partial void Leave_selectStatement();

	// $ANTLR start "selectStatement"
	// SQL.g:58:1: selectStatement : select_1 -> {!isUnion}? ^( SelectStmt select_1 ) ->;
	[GrammarRule("selectStatement")]
	private SQLParser.selectStatement_return selectStatement()
	{
		Enter_selectStatement();
		EnterRule("selectStatement", 4);
		TraceIn("selectStatement", 4);
		SQLParser.selectStatement_return retval = new SQLParser.selectStatement_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.select_1_return select_16 = default(SQLParser.select_1_return);

		RewriteRuleSubtreeStream stream_select_1=new RewriteRuleSubtreeStream(adaptor,"rule select_1");
		try { DebugEnterRule(GrammarFileName, "selectStatement");
		DebugLocation(58, 1);
		try
		{
			// SQL.g:59:2: ( select_1 -> {!isUnion}? ^( SelectStmt select_1 ) ->)
			DebugEnterAlt(1);
			// SQL.g:59:4: select_1
			{
			DebugLocation(59, 4);
			bool isUnion=false;
			DebugLocation(59, 26);
			PushFollow(Follow._select_1_in_selectStatement355);
			select_16=select_1();
			PopFollow();

			stream_select_1.Add(select_16.Tree);


			{
			// AST REWRITE
			// elements: select_1
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 61:4: -> {!isUnion}? ^( SelectStmt select_1 )
			if (!isUnion)
			{
				DebugLocation(61, 18);
				// SQL.g:61:18: ^( SelectStmt select_1 )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(61, 20);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(SelectStmt, "SelectStmt"), root_1);

				DebugLocation(61, 31);
				adaptor.AddChild(root_1, stream_select_1.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}
			else // 62:4: ->
			{
				DebugLocation(63, 2);
				root_0 = null;
			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("selectStatement", 4);
			LeaveRule("selectStatement", 4);
			Leave_selectStatement();
		}
		DebugLocation(63, 1);
		} finally { DebugExitRule(GrammarFileName, "selectStatement"); }
		return retval;

	}
	// $ANTLR end "selectStatement"

	public class select_1_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_select_1();
	partial void Leave_select_1();

	// $ANTLR start "select_1"
	// SQL.g:65:1: select_1 : select ( from )? ( where )? ;
	[GrammarRule("select_1")]
	private SQLParser.select_1_return select_1()
	{
		Enter_select_1();
		EnterRule("select_1", 5);
		TraceIn("select_1", 5);
		SQLParser.select_1_return retval = new SQLParser.select_1_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.select_return select7 = default(SQLParser.select_return);
		SQLParser.from_return from8 = default(SQLParser.from_return);
		SQLParser.where_return where9 = default(SQLParser.where_return);


		try { DebugEnterRule(GrammarFileName, "select_1");
		DebugLocation(65, 29);
		try
		{
			// SQL.g:65:9: ( select ( from )? ( where )? )
			DebugEnterAlt(1);
			// SQL.g:65:11: select ( from )? ( where )?
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(65, 11);
			PushFollow(Follow._select_in_select_1384);
			select7=select();
			PopFollow();

			adaptor.AddChild(root_0, select7.Tree);
			DebugLocation(65, 18);
			// SQL.g:65:18: ( from )?
			int alt3=2;
			try { DebugEnterSubRule(3);
			try { DebugEnterDecision(3, decisionCanBacktrack[3]);
			int LA3_0 = input.LA(1);

			if ((LA3_0==FROM))
			{
				alt3=1;
			}
			} finally { DebugExitDecision(3); }
			switch (alt3)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:65:18: from
				{
				DebugLocation(65, 18);
				PushFollow(Follow._from_in_select_1386);
				from8=from();
				PopFollow();

				adaptor.AddChild(root_0, from8.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(3); }

			DebugLocation(65, 24);
			// SQL.g:65:24: ( where )?
			int alt4=2;
			try { DebugEnterSubRule(4);
			try { DebugEnterDecision(4, decisionCanBacktrack[4]);
			int LA4_0 = input.LA(1);

			if ((LA4_0==WHERE))
			{
				alt4=1;
			}
			} finally { DebugExitDecision(4); }
			switch (alt4)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:65:24: where
				{
				DebugLocation(65, 24);
				PushFollow(Follow._where_in_select_1389);
				where9=where();
				PopFollow();

				adaptor.AddChild(root_0, where9.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(4); }


			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("select_1", 5);
			LeaveRule("select_1", 5);
			Leave_select_1();
		}
		DebugLocation(65, 29);
		} finally { DebugExitRule(GrammarFileName, "select_1"); }
		return retval;

	}
	// $ANTLR end "select_1"

	public class select_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_select();
	partial void Leave_select();

	// $ANTLR start "select"
	// SQL.g:73:1: select : SELECT columns -> ^( SelectClause SELECT columns ) ;
	[GrammarRule("select")]
	private SQLParser.select_return select()
	{
		Enter_select();
		EnterRule("select", 6);
		TraceIn("select", 6);
		SQLParser.select_return retval = new SQLParser.select_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken SELECT10=null;
		SQLParser.columns_return columns11 = default(SQLParser.columns_return);

		Expression SELECT10_tree=null;
		RewriteRuleITokenStream stream_SELECT=new RewriteRuleITokenStream(adaptor,"token SELECT");
		RewriteRuleSubtreeStream stream_columns=new RewriteRuleSubtreeStream(adaptor,"rule columns");
		try { DebugEnterRule(GrammarFileName, "select");
		DebugLocation(73, 1);
		try
		{
			// SQL.g:74:2: ( SELECT columns -> ^( SelectClause SELECT columns ) )
			DebugEnterAlt(1);
			// SQL.g:74:4: SELECT columns
			{
			DebugLocation(74, 4);
			SELECT10=(IToken)Match(input,SELECT,Follow._SELECT_in_select406);  
			stream_SELECT.Add(SELECT10);

			DebugLocation(74, 12);
			PushFollow(Follow._columns_in_select409);
			columns11=columns();
			PopFollow();

			stream_columns.Add(columns11.Tree);


			{
			// AST REWRITE
			// elements: columns, SELECT
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 75:2: -> ^( SelectClause SELECT columns )
			{
				DebugLocation(75, 5);
				// SQL.g:75:5: ^( SelectClause SELECT columns )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(75, 7);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(SelectClause, "SelectClause"), root_1);

				DebugLocation(75, 20);
				adaptor.AddChild(root_1, stream_SELECT.NextNode());
				DebugLocation(75, 28);
				adaptor.AddChild(root_1, stream_columns.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("select", 6);
			LeaveRule("select", 6);
			Leave_select();
		}
		DebugLocation(76, 1);
		} finally { DebugExitRule(GrammarFileName, "select"); }
		return retval;

	}
	// $ANTLR end "select"

	public class from_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_from();
	partial void Leave_from();

	// $ANTLR start "from"
	// SQL.g:77:1: from : FROM tables ;
	[GrammarRule("from")]
	private SQLParser.from_return from()
	{
		Enter_from();
		EnterRule("from", 7);
		TraceIn("from", 7);
		SQLParser.from_return retval = new SQLParser.from_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken FROM12=null;
		SQLParser.tables_return tables13 = default(SQLParser.tables_return);

		Expression FROM12_tree=null;

		try { DebugEnterRule(GrammarFileName, "from");
		DebugLocation(77, 19);
		try
		{
			// SQL.g:77:5: ( FROM tables )
			DebugEnterAlt(1);
			// SQL.g:77:7: FROM tables
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(77, 11);
			FROM12=(IToken)Match(input,FROM,Follow._FROM_in_from429); 
			FROM12_tree = (Expression)adaptor.Create(FROM12);
			root_0 = (Expression)adaptor.BecomeRoot(FROM12_tree, root_0);

			DebugLocation(77, 13);
			PushFollow(Follow._tables_in_from432);
			tables13=tables();
			PopFollow();

			adaptor.AddChild(root_0, tables13.Tree);

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("from", 7);
			LeaveRule("from", 7);
			Leave_from();
		}
		DebugLocation(77, 19);
		} finally { DebugExitRule(GrammarFileName, "from"); }
		return retval;

	}
	// $ANTLR end "from"

	public class where_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_where();
	partial void Leave_where();

	// $ANTLR start "where"
	// SQL.g:78:1: where : WHERE condition -> ^( WhereClause WHERE condition ) ;
	[GrammarRule("where")]
	private SQLParser.where_return where()
	{
		Enter_where();
		EnterRule("where", 8);
		TraceIn("where", 8);
		SQLParser.where_return retval = new SQLParser.where_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken WHERE14=null;
		SQLParser.condition_return condition15 = default(SQLParser.condition_return);

		Expression WHERE14_tree=null;
		RewriteRuleITokenStream stream_WHERE=new RewriteRuleITokenStream(adaptor,"token WHERE");
		RewriteRuleSubtreeStream stream_condition=new RewriteRuleSubtreeStream(adaptor,"rule condition");
		try { DebugEnterRule(GrammarFileName, "where");
		DebugLocation(78, 57);
		try
		{
			// SQL.g:78:6: ( WHERE condition -> ^( WhereClause WHERE condition ) )
			DebugEnterAlt(1);
			// SQL.g:78:8: WHERE condition
			{
			DebugLocation(78, 8);
			WHERE14=(IToken)Match(input,WHERE,Follow._WHERE_in_where439);  
			stream_WHERE.Add(WHERE14);

			DebugLocation(78, 14);
			PushFollow(Follow._condition_in_where441);
			condition15=condition();
			PopFollow();

			stream_condition.Add(condition15.Tree);


			{
			// AST REWRITE
			// elements: WHERE, condition
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 78:24: -> ^( WhereClause WHERE condition )
			{
				DebugLocation(78, 27);
				// SQL.g:78:27: ^( WhereClause WHERE condition )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(78, 29);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(WhereClause, "WhereClause"), root_1);

				DebugLocation(78, 41);
				adaptor.AddChild(root_1, stream_WHERE.NextNode());
				DebugLocation(78, 47);
				adaptor.AddChild(root_1, stream_condition.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("where", 8);
			LeaveRule("where", 8);
			Leave_where();
		}
		DebugLocation(78, 57);
		} finally { DebugExitRule(GrammarFileName, "where"); }
		return retval;

	}
	// $ANTLR end "where"

	public class columns_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_columns();
	partial void Leave_columns();

	// $ANTLR start "columns"
	// SQL.g:112:1: columns : column ( COMMA column )* -> ( column )+ ;
	[GrammarRule("columns")]
	private SQLParser.columns_return columns()
	{
		Enter_columns();
		EnterRule("columns", 9);
		TraceIn("columns", 9);
		SQLParser.columns_return retval = new SQLParser.columns_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken COMMA17=null;
		SQLParser.column_return column16 = default(SQLParser.column_return);
		SQLParser.column_return column18 = default(SQLParser.column_return);

		Expression COMMA17_tree=null;
		RewriteRuleITokenStream stream_COMMA=new RewriteRuleITokenStream(adaptor,"token COMMA");
		RewriteRuleSubtreeStream stream_column=new RewriteRuleSubtreeStream(adaptor,"rule column");
		try { DebugEnterRule(GrammarFileName, "columns");
		DebugLocation(112, 44);
		try
		{
			// SQL.g:112:8: ( column ( COMMA column )* -> ( column )+ )
			DebugEnterAlt(1);
			// SQL.g:112:10: column ( COMMA column )*
			{
			DebugLocation(112, 10);
			PushFollow(Follow._column_in_columns462);
			column16=column();
			PopFollow();

			stream_column.Add(column16.Tree);
			DebugLocation(112, 17);
			// SQL.g:112:17: ( COMMA column )*
			try { DebugEnterSubRule(5);
			while (true)
			{
				int alt5=2;
				try { DebugEnterDecision(5, decisionCanBacktrack[5]);
				int LA5_0 = input.LA(1);

				if ((LA5_0==COMMA))
				{
					alt5=1;
				}


				} finally { DebugExitDecision(5); }
				switch ( alt5 )
				{
				case 1:
					DebugEnterAlt(1);
					// SQL.g:112:19: COMMA column
					{
					DebugLocation(112, 19);
					COMMA17=(IToken)Match(input,COMMA,Follow._COMMA_in_columns466);  
					stream_COMMA.Add(COMMA17);

					DebugLocation(112, 25);
					PushFollow(Follow._column_in_columns468);
					column18=column();
					PopFollow();

					stream_column.Add(column18.Tree);

					}
					break;

				default:
					goto loop5;
				}
			}

			loop5:
				;

			} finally { DebugExitSubRule(5); }



			{
			// AST REWRITE
			// elements: column
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 112:35: -> ( column )+
			{
				DebugLocation(112, 38);
				if ( !(stream_column.HasNext) )
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_column.HasNext )
				{
					DebugLocation(112, 38);
					adaptor.AddChild(root_0, stream_column.NextTree());

				}
				stream_column.Reset();

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("columns", 9);
			LeaveRule("columns", 9);
			Leave_columns();
		}
		DebugLocation(112, 44);
		} finally { DebugExitRule(GrammarFileName, "columns"); }
		return retval;

	}
	// $ANTLR end "columns"

	public class column_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_column();
	partial void Leave_column();

	// $ANTLR start "column"
	// SQL.g:113:1: column : ( MUL -> ^( Column MUL ) | identifier DOT MUL -> ^( Column identifier DOT MUL ) | expressions -> ^( Column expressions ) );
	[GrammarRule("column")]
	private SQLParser.column_return column()
	{
		Enter_column();
		EnterRule("column", 10);
		TraceIn("column", 10);
		SQLParser.column_return retval = new SQLParser.column_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken MUL19=null;
		IToken DOT21=null;
		IToken MUL22=null;
		SQLParser.identifier_return identifier20 = default(SQLParser.identifier_return);
		SQLParser.expressions_return expressions23 = default(SQLParser.expressions_return);

		Expression MUL19_tree=null;
		Expression DOT21_tree=null;
		Expression MUL22_tree=null;
		RewriteRuleITokenStream stream_DOT=new RewriteRuleITokenStream(adaptor,"token DOT");
		RewriteRuleITokenStream stream_MUL=new RewriteRuleITokenStream(adaptor,"token MUL");
		RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
		RewriteRuleSubtreeStream stream_expressions=new RewriteRuleSubtreeStream(adaptor,"rule expressions");
		try { DebugEnterRule(GrammarFileName, "column");
		DebugLocation(113, 6);
		try
		{
			// SQL.g:114:2: ( MUL -> ^( Column MUL ) | identifier DOT MUL -> ^( Column identifier DOT MUL ) | expressions -> ^( Column expressions ) )
			int alt6=3;
			try { DebugEnterDecision(6, decisionCanBacktrack[6]);
			switch (input.LA(1))
			{
			case MUL:
				{
				alt6=1;
				}
				break;
			case NonQuotedIdentifier:
				{
				int LA6_2 = input.LA(2);

				if ((LA6_2==DOT))
				{
					alt6=2;
				}
				else if ((LA6_2==EOF||(LA6_2>=COMMA && LA6_2<=SEMI)||(LA6_2>=SELECT && LA6_2<=WHERE)))
				{
					alt6=3;
				}
				else
				{
					NoViableAltException nvae = new NoViableAltException("", 6, 2, input);

					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case MINUS:
			case Integer:
			case Txt:
				{
				alt6=3;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 6, 0, input);

					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(6); }
			switch (alt6)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:114:4: MUL
				{
				DebugLocation(114, 4);
				MUL19=(IToken)Match(input,MUL,Follow._MUL_in_column485);  
				stream_MUL.Add(MUL19);



				{
				// AST REWRITE
				// elements: MUL
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (Expression)adaptor.Nil();
				// 114:8: -> ^( Column MUL )
				{
					DebugLocation(114, 11);
					// SQL.g:114:11: ^( Column MUL )
					{
					Expression root_1 = (Expression)adaptor.Nil();
					DebugLocation(114, 13);
					root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Column, "Column"), root_1);

					DebugLocation(114, 20);
					adaptor.AddChild(root_1, stream_MUL.NextNode());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SQL.g:115:6: identifier DOT MUL
				{
				DebugLocation(115, 6);
				PushFollow(Follow._identifier_in_column501);
				identifier20=identifier();
				PopFollow();

				stream_identifier.Add(identifier20.Tree);
				DebugLocation(115, 17);
				DOT21=(IToken)Match(input,DOT,Follow._DOT_in_column503);  
				stream_DOT.Add(DOT21);

				DebugLocation(115, 21);
				MUL22=(IToken)Match(input,MUL,Follow._MUL_in_column505);  
				stream_MUL.Add(MUL22);



				{
				// AST REWRITE
				// elements: MUL, DOT, identifier
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (Expression)adaptor.Nil();
				// 115:25: -> ^( Column identifier DOT MUL )
				{
					DebugLocation(115, 28);
					// SQL.g:115:28: ^( Column identifier DOT MUL )
					{
					Expression root_1 = (Expression)adaptor.Nil();
					DebugLocation(115, 30);
					root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Column, "Column"), root_1);

					DebugLocation(115, 37);
					adaptor.AddChild(root_1, stream_identifier.NextTree());
					DebugLocation(115, 48);
					adaptor.AddChild(root_1, stream_DOT.NextNode());
					DebugLocation(115, 52);
					adaptor.AddChild(root_1, stream_MUL.NextNode());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SQL.g:116:9: expressions
				{
				DebugLocation(116, 9);
				PushFollow(Follow._expressions_in_column528);
				expressions23=expressions();
				PopFollow();

				stream_expressions.Add(expressions23.Tree);


				{
				// AST REWRITE
				// elements: expressions
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (Expression)adaptor.Nil();
				// 116:39: -> ^( Column expressions )
				{
					DebugLocation(116, 42);
					// SQL.g:116:42: ^( Column expressions )
					{
					Expression root_1 = (Expression)adaptor.Nil();
					DebugLocation(116, 44);
					root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Column, "Column"), root_1);

					DebugLocation(116, 51);
					adaptor.AddChild(root_1, stream_expressions.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("column", 10);
			LeaveRule("column", 10);
			Leave_column();
		}
		DebugLocation(117, 6);
		} finally { DebugExitRule(GrammarFileName, "column"); }
		return retval;

	}
	// $ANTLR end "column"

	public class tables_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_tables();
	partial void Leave_tables();

	// $ANTLR start "tables"
	// SQL.g:118:1: tables : table ( tables_0 )* ;
	[GrammarRule("tables")]
	private SQLParser.tables_return tables()
	{
		Enter_tables();
		EnterRule("tables", 11);
		TraceIn("tables", 11);
		SQLParser.tables_return retval = new SQLParser.tables_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.table_return table24 = default(SQLParser.table_return);
		SQLParser.tables_0_return tables_025 = default(SQLParser.tables_0_return);


		try { DebugEnterRule(GrammarFileName, "tables");
		DebugLocation(118, 23);
		try
		{
			// SQL.g:118:7: ( table ( tables_0 )* )
			DebugEnterAlt(1);
			// SQL.g:118:9: table ( tables_0 )*
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(118, 9);
			PushFollow(Follow._table_in_tables554);
			table24=table();
			PopFollow();

			adaptor.AddChild(root_0, table24.Tree);
			DebugLocation(118, 15);
			// SQL.g:118:15: ( tables_0 )*
			try { DebugEnterSubRule(7);
			while (true)
			{
				int alt7=2;
				try { DebugEnterDecision(7, decisionCanBacktrack[7]);
				int LA7_0 = input.LA(1);

				if ((LA7_0==COMMA))
				{
					alt7=1;
				}


				} finally { DebugExitDecision(7); }
				switch ( alt7 )
				{
				case 1:
					DebugEnterAlt(1);
					// SQL.g:118:15: tables_0
					{
					DebugLocation(118, 15);
					PushFollow(Follow._tables_0_in_tables556);
					tables_025=tables_0();
					PopFollow();

					adaptor.AddChild(root_0, tables_025.Tree);

					}
					break;

				default:
					goto loop7;
				}
			}

			loop7:
				;

			} finally { DebugExitSubRule(7); }


			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("tables", 11);
			LeaveRule("tables", 11);
			Leave_tables();
		}
		DebugLocation(118, 23);
		} finally { DebugExitRule(GrammarFileName, "tables"); }
		return retval;

	}
	// $ANTLR end "tables"

	public class tables_0_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_tables_0();
	partial void Leave_tables_0();

	// $ANTLR start "tables_0"
	// SQL.g:119:1: tables_0 : ( COMMA table -> table ) ;
	[GrammarRule("tables_0")]
	private SQLParser.tables_0_return tables_0()
	{
		Enter_tables_0();
		EnterRule("tables_0", 12);
		TraceIn("tables_0", 12);
		SQLParser.tables_0_return retval = new SQLParser.tables_0_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken COMMA26=null;
		SQLParser.table_return table27 = default(SQLParser.table_return);

		Expression COMMA26_tree=null;
		RewriteRuleITokenStream stream_COMMA=new RewriteRuleITokenStream(adaptor,"token COMMA");
		RewriteRuleSubtreeStream stream_table=new RewriteRuleSubtreeStream(adaptor,"rule table");
		try { DebugEnterRule(GrammarFileName, "tables_0");
		DebugLocation(119, 32);
		try
		{
			// SQL.g:119:9: ( ( COMMA table -> table ) )
			DebugEnterAlt(1);
			// SQL.g:119:11: ( COMMA table -> table )
			{
			DebugLocation(119, 11);
			// SQL.g:119:11: ( COMMA table -> table )
			DebugEnterAlt(1);
			// SQL.g:119:12: COMMA table
			{
			DebugLocation(119, 12);
			COMMA26=(IToken)Match(input,COMMA,Follow._COMMA_in_tables_0564);  
			stream_COMMA.Add(COMMA26);

			DebugLocation(119, 18);
			PushFollow(Follow._table_in_tables_0566);
			table27=table();
			PopFollow();

			stream_table.Add(table27.Tree);


			{
			// AST REWRITE
			// elements: table
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 119:24: -> table
			{
				DebugLocation(119, 27);
				adaptor.AddChild(root_0, stream_table.NextTree());

			}

			retval.Tree = root_0;
			}

			}


			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("tables_0", 12);
			LeaveRule("tables_0", 12);
			Leave_tables_0();
		}
		DebugLocation(119, 32);
		} finally { DebugExitRule(GrammarFileName, "tables_0"); }
		return retval;

	}
	// $ANTLR end "tables_0"

	public class table_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_table();
	partial void Leave_table();

	// $ANTLR start "table"
	// SQL.g:120:1: table : ( | identifier -> ^( Table identifier ) );
	[GrammarRule("table")]
	private SQLParser.table_return table()
	{
		Enter_table();
		EnterRule("table", 13);
		TraceIn("table", 13);
		SQLParser.table_return retval = new SQLParser.table_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.identifier_return identifier28 = default(SQLParser.identifier_return);

		RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
		try { DebugEnterRule(GrammarFileName, "table");
		DebugLocation(120, 4);
		try
		{
			// SQL.g:121:5: ( | identifier -> ^( Table identifier ) )
			int alt8=2;
			try { DebugEnterDecision(8, decisionCanBacktrack[8]);
			int LA8_0 = input.LA(1);

			if ((LA8_0==EOF||(LA8_0>=COMMA && LA8_0<=SEMI)||LA8_0==SELECT||LA8_0==WHERE))
			{
				alt8=1;
			}
			else if ((LA8_0==NonQuotedIdentifier))
			{
				alt8=2;
			}
			else
			{
				NoViableAltException nvae = new NoViableAltException("", 8, 0, input);

				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(8); }
			switch (alt8)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:122:5: 
				{
				root_0 = (Expression)adaptor.Nil();

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SQL.g:122:7: identifier
				{
				DebugLocation(122, 7);
				PushFollow(Follow._identifier_in_table591);
				identifier28=identifier();
				PopFollow();

				stream_identifier.Add(identifier28.Tree);


				{
				// AST REWRITE
				// elements: identifier
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (Expression)adaptor.Nil();
				// 123:7: -> ^( Table identifier )
				{
					DebugLocation(123, 10);
					// SQL.g:123:10: ^( Table identifier )
					{
					Expression root_1 = (Expression)adaptor.Nil();
					DebugLocation(123, 12);
					root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Table, "Table"), root_1);

					DebugLocation(123, 18);
					adaptor.AddChild(root_1, stream_identifier.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("table", 13);
			LeaveRule("table", 13);
			Leave_table();
		}
		DebugLocation(124, 4);
		} finally { DebugExitRule(GrammarFileName, "table"); }
		return retval;

	}
	// $ANTLR end "table"

	public class condition_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_condition();
	partial void Leave_condition();

	// $ANTLR start "condition"
	// SQL.g:141:1: condition : subCondition ( ( AND | OR ) subCondition )* ;
	[GrammarRule("condition")]
	private SQLParser.condition_return condition()
	{
		Enter_condition();
		EnterRule("condition", 14);
		TraceIn("condition", 14);
		SQLParser.condition_return retval = new SQLParser.condition_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken AND30=null;
		IToken OR31=null;
		SQLParser.subCondition_return subCondition29 = default(SQLParser.subCondition_return);
		SQLParser.subCondition_return subCondition32 = default(SQLParser.subCondition_return);

		Expression AND30_tree=null;
		Expression OR31_tree=null;

		try { DebugEnterRule(GrammarFileName, "condition");
		DebugLocation(141, 54);
		try
		{
			// SQL.g:141:10: ( subCondition ( ( AND | OR ) subCondition )* )
			DebugEnterAlt(1);
			// SQL.g:141:12: subCondition ( ( AND | OR ) subCondition )*
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(141, 12);
			PushFollow(Follow._subCondition_in_condition625);
			subCondition29=subCondition();
			PopFollow();

			adaptor.AddChild(root_0, subCondition29.Tree);
			DebugLocation(141, 25);
			// SQL.g:141:25: ( ( AND | OR ) subCondition )*
			try { DebugEnterSubRule(10);
			while (true)
			{
				int alt10=2;
				try { DebugEnterDecision(10, decisionCanBacktrack[10]);
				int LA10_0 = input.LA(1);

				if (((LA10_0>=AND && LA10_0<=OR)))
				{
					alt10=1;
				}


				} finally { DebugExitDecision(10); }
				switch ( alt10 )
				{
				case 1:
					DebugEnterAlt(1);
					// SQL.g:141:26: ( AND | OR ) subCondition
					{
					DebugLocation(141, 26);
					// SQL.g:141:26: ( AND | OR )
					int alt9=2;
					try { DebugEnterSubRule(9);
					try { DebugEnterDecision(9, decisionCanBacktrack[9]);
					int LA9_0 = input.LA(1);

					if ((LA9_0==AND))
					{
						alt9=1;
					}
					else if ((LA9_0==OR))
					{
						alt9=2;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 9, 0, input);

						DebugRecognitionException(nvae);
						throw nvae;
					}
					} finally { DebugExitDecision(9); }
					switch (alt9)
					{
					case 1:
						DebugEnterAlt(1);
						// SQL.g:141:27: AND
						{
						DebugLocation(141, 31);
						AND30=(IToken)Match(input,AND,Follow._AND_in_condition629); 
						AND30_tree = (Expression)adaptor.Create(AND30);
						root_0 = (Expression)adaptor.BecomeRoot(AND30_tree, root_0);


						}
						break;
					case 2:
						DebugEnterAlt(2);
						// SQL.g:141:35: OR
						{
						DebugLocation(141, 38);
						OR31=(IToken)Match(input,OR,Follow._OR_in_condition635); 
						OR31_tree = (Expression)adaptor.Create(OR31);
						root_0 = (Expression)adaptor.BecomeRoot(OR31_tree, root_0);


						}
						break;

					}
					} finally { DebugExitSubRule(9); }

					DebugLocation(141, 41);
					PushFollow(Follow._subCondition_in_condition640);
					subCondition32=subCondition();
					PopFollow();

					adaptor.AddChild(root_0, subCondition32.Tree);

					}
					break;

				default:
					goto loop10;
				}
			}

			loop10:
				;

			} finally { DebugExitSubRule(10); }


			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("condition", 14);
			LeaveRule("condition", 14);
			Leave_condition();
		}
		DebugLocation(141, 54);
		} finally { DebugExitRule(GrammarFileName, "condition"); }
		return retval;

	}
	// $ANTLR end "condition"

	public class subCondition_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_subCondition();
	partial void Leave_subCondition();

	// $ANTLR start "subCondition"
	// SQL.g:142:1: subCondition : ( NOT )? ( LPAREN condition RPAREN | e= predicate ) -> {prefixNot && isGroup}? ^( NOT ^( Group condition ) ) -> {prefixNot && !isGroup}? ^( NOT $e) -> {!prefixNot && isGroup}? ^( Group condition ) -> {!prefixNot && !isGroup}? $e ->;
	[GrammarRule("subCondition")]
	private SQLParser.subCondition_return subCondition()
	{
		Enter_subCondition();
		EnterRule("subCondition", 15);
		TraceIn("subCondition", 15);
		SQLParser.subCondition_return retval = new SQLParser.subCondition_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken NOT33=null;
		IToken LPAREN34=null;
		IToken RPAREN36=null;
		SQLParser.predicate_return e = default(SQLParser.predicate_return);
		SQLParser.condition_return condition35 = default(SQLParser.condition_return);

		Expression NOT33_tree=null;
		Expression LPAREN34_tree=null;
		Expression RPAREN36_tree=null;
		RewriteRuleITokenStream stream_RPAREN=new RewriteRuleITokenStream(adaptor,"token RPAREN");
		RewriteRuleITokenStream stream_NOT=new RewriteRuleITokenStream(adaptor,"token NOT");
		RewriteRuleITokenStream stream_LPAREN=new RewriteRuleITokenStream(adaptor,"token LPAREN");
		RewriteRuleSubtreeStream stream_condition=new RewriteRuleSubtreeStream(adaptor,"rule condition");
		RewriteRuleSubtreeStream stream_predicate=new RewriteRuleSubtreeStream(adaptor,"rule predicate");
		try { DebugEnterRule(GrammarFileName, "subCondition");
		DebugLocation(142, 1);
		try
		{
			// SQL.g:142:13: ( ( NOT )? ( LPAREN condition RPAREN | e= predicate ) -> {prefixNot && isGroup}? ^( NOT ^( Group condition ) ) -> {prefixNot && !isGroup}? ^( NOT $e) -> {!prefixNot && isGroup}? ^( Group condition ) -> {!prefixNot && !isGroup}? $e ->)
			DebugEnterAlt(1);
			// SQL.g:143:2: ( NOT )? ( LPAREN condition RPAREN | e= predicate )
			{
			DebugLocation(143, 2);
			bool prefixNot=false;bool isGroup=false;
			DebugLocation(143, 44);
			// SQL.g:143:44: ( NOT )?
			int alt11=2;
			try { DebugEnterSubRule(11);
			try { DebugEnterDecision(11, decisionCanBacktrack[11]);
			int LA11_0 = input.LA(1);

			if ((LA11_0==NOT))
			{
				alt11=1;
			}
			} finally { DebugExitDecision(11); }
			switch (alt11)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:143:45: NOT
				{
				DebugLocation(143, 45);
				NOT33=(IToken)Match(input,NOT,Follow._NOT_in_subCondition652);  
				stream_NOT.Add(NOT33);

				DebugLocation(143, 49);
				prefixNot=true;

				}
				break;

			}
			} finally { DebugExitSubRule(11); }

			DebugLocation(143, 69);
			// SQL.g:143:69: ( LPAREN condition RPAREN | e= predicate )
			int alt12=2;
			try { DebugEnterSubRule(12);
			try { DebugEnterDecision(12, decisionCanBacktrack[12]);
			int LA12_0 = input.LA(1);

			if ((LA12_0==LPAREN))
			{
				alt12=1;
			}
			else if ((LA12_0==MINUS||(LA12_0>=NonQuotedIdentifier && LA12_0<=Txt)))
			{
				alt12=2;
			}
			else
			{
				NoViableAltException nvae = new NoViableAltException("", 12, 0, input);

				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(12); }
			switch (alt12)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:144:4: LPAREN condition RPAREN
				{
				DebugLocation(144, 4);
				LPAREN34=(IToken)Match(input,LPAREN,Follow._LPAREN_in_subCondition663);  
				stream_LPAREN.Add(LPAREN34);

				DebugLocation(144, 11);
				PushFollow(Follow._condition_in_subCondition665);
				condition35=condition();
				PopFollow();

				stream_condition.Add(condition35.Tree);
				DebugLocation(144, 21);
				RPAREN36=(IToken)Match(input,RPAREN,Follow._RPAREN_in_subCondition667);  
				stream_RPAREN.Add(RPAREN36);

				DebugLocation(144, 28);
				isGroup=true;

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SQL.g:145:6: e= predicate
				{
				DebugLocation(145, 7);
				PushFollow(Follow._predicate_in_subCondition678);
				e=predicate();
				PopFollow();

				stream_predicate.Add(e.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(12); }



			{
			// AST REWRITE
			// elements: e, condition, condition, NOT, e, NOT
			// token labels: 
			// rule labels: retval, e
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
			RewriteRuleSubtreeStream stream_e=new RewriteRuleSubtreeStream(adaptor,"rule e",e!=null?e.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 147:2: -> {prefixNot && isGroup}? ^( NOT ^( Group condition ) )
			if (prefixNot && isGroup)
			{
				DebugLocation(147, 29);
				// SQL.g:147:29: ^( NOT ^( Group condition ) )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(147, 31);
				root_1 = (Expression)adaptor.BecomeRoot(stream_NOT.NextNode(), root_1);

				DebugLocation(147, 35);
				// SQL.g:147:35: ^( Group condition )
				{
				Expression root_2 = (Expression)adaptor.Nil();
				DebugLocation(147, 37);
				root_2 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Group, "Group"), root_2);

				DebugLocation(147, 43);
				adaptor.AddChild(root_2, stream_condition.NextTree());

				adaptor.AddChild(root_1, root_2);
				}

				adaptor.AddChild(root_0, root_1);
				}

			}
			else // 148:2: -> {prefixNot && !isGroup}? ^( NOT $e)
			if (prefixNot && !isGroup)
			{
				DebugLocation(148, 30);
				// SQL.g:148:30: ^( NOT $e)
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(148, 32);
				root_1 = (Expression)adaptor.BecomeRoot(stream_NOT.NextNode(), root_1);

				DebugLocation(148, 36);
				adaptor.AddChild(root_1, stream_e.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}
			else // 149:2: -> {!prefixNot && isGroup}? ^( Group condition )
			if (!prefixNot && isGroup)
			{
				DebugLocation(149, 30);
				// SQL.g:149:30: ^( Group condition )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(149, 32);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Group, "Group"), root_1);

				DebugLocation(149, 38);
				adaptor.AddChild(root_1, stream_condition.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}
			else // 150:2: -> {!prefixNot && !isGroup}? $e
			if (!prefixNot && !isGroup)
			{
				DebugLocation(150, 31);
				adaptor.AddChild(root_0, stream_e.NextTree());

			}
			else // 151:2: ->
			{
				DebugLocation(152, 2);
				root_0 = null;
			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("subCondition", 15);
			LeaveRule("subCondition", 15);
			Leave_subCondition();
		}
		DebugLocation(152, 1);
		} finally { DebugExitRule(GrammarFileName, "subCondition"); }
		return retval;

	}
	// $ANTLR end "subCondition"

	public class predicate_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_predicate();
	partial void Leave_predicate();

	// $ANTLR start "predicate"
	// SQL.g:153:1: predicate : expressions ( comparisonOperator expressions ) -> ^( Predicate expressions comparisonOperator expressions ) ;
	[GrammarRule("predicate")]
	private SQLParser.predicate_return predicate()
	{
		Enter_predicate();
		EnterRule("predicate", 16);
		TraceIn("predicate", 16);
		SQLParser.predicate_return retval = new SQLParser.predicate_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.expressions_return expressions37 = default(SQLParser.expressions_return);
		SQLParser.comparisonOperator_return comparisonOperator38 = default(SQLParser.comparisonOperator_return);
		SQLParser.expressions_return expressions39 = default(SQLParser.expressions_return);

		RewriteRuleSubtreeStream stream_comparisonOperator=new RewriteRuleSubtreeStream(adaptor,"rule comparisonOperator");
		RewriteRuleSubtreeStream stream_expressions=new RewriteRuleSubtreeStream(adaptor,"rule expressions");
		try { DebugEnterRule(GrammarFileName, "predicate");
		DebugLocation(153, 1);
		try
		{
			// SQL.g:154:2: ( expressions ( comparisonOperator expressions ) -> ^( Predicate expressions comparisonOperator expressions ) )
			DebugEnterAlt(1);
			// SQL.g:154:4: expressions ( comparisonOperator expressions )
			{
			DebugLocation(154, 4);
			PushFollow(Follow._expressions_in_predicate740);
			expressions37=expressions();
			PopFollow();

			stream_expressions.Add(expressions37.Tree);
			DebugLocation(154, 16);
			// SQL.g:154:16: ( comparisonOperator expressions )
			DebugEnterAlt(1);
			// SQL.g:154:17: comparisonOperator expressions
			{
			DebugLocation(154, 17);
			PushFollow(Follow._comparisonOperator_in_predicate743);
			comparisonOperator38=comparisonOperator();
			PopFollow();

			stream_comparisonOperator.Add(comparisonOperator38.Tree);
			DebugLocation(154, 37);
			PushFollow(Follow._expressions_in_predicate746);
			expressions39=expressions();
			PopFollow();

			stream_expressions.Add(expressions39.Tree);

			}



			{
			// AST REWRITE
			// elements: comparisonOperator, expressions, expressions
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 155:4: -> ^( Predicate expressions comparisonOperator expressions )
			{
				DebugLocation(155, 7);
				// SQL.g:155:7: ^( Predicate expressions comparisonOperator expressions )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(155, 9);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(Predicate, "Predicate"), root_1);

				DebugLocation(155, 19);
				adaptor.AddChild(root_1, stream_expressions.NextTree());
				DebugLocation(155, 31);
				adaptor.AddChild(root_1, stream_comparisonOperator.NextTree());
				DebugLocation(155, 51);
				adaptor.AddChild(root_1, stream_expressions.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("predicate", 16);
			LeaveRule("predicate", 16);
			Leave_predicate();
		}
		DebugLocation(166, 1);
		} finally { DebugExitRule(GrammarFileName, "predicate"); }
		return retval;

	}
	// $ANTLR end "predicate"

	public class expressions_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_expressions();
	partial void Leave_expressions();

	// $ANTLR start "expressions"
	// SQL.g:168:1: expressions : expression ;
	[GrammarRule("expressions")]
	private SQLParser.expressions_return expressions()
	{
		Enter_expressions();
		EnterRule("expressions", 17);
		TraceIn("expressions", 17);
		SQLParser.expressions_return retval = new SQLParser.expressions_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.expression_return expression40 = default(SQLParser.expression_return);


		try { DebugEnterRule(GrammarFileName, "expressions");
		DebugLocation(168, 23);
		try
		{
			// SQL.g:168:12: ( expression )
			DebugEnterAlt(1);
			// SQL.g:168:14: expression
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(168, 14);
			PushFollow(Follow._expression_in_expressions792);
			expression40=expression();
			PopFollow();

			adaptor.AddChild(root_0, expression40.Tree);

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("expressions", 17);
			LeaveRule("expressions", 17);
			Leave_expressions();
		}
		DebugLocation(168, 23);
		} finally { DebugExitRule(GrammarFileName, "expressions"); }
		return retval;

	}
	// $ANTLR end "expressions"

	public class expression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_expression();
	partial void Leave_expression();

	// $ANTLR start "expression"
	// SQL.g:171:1: expression : ( identifier | constant_int | constant_txt );
	[GrammarRule("expression")]
	private SQLParser.expression_return expression()
	{
		Enter_expression();
		EnterRule("expression", 18);
		TraceIn("expression", 18);
		SQLParser.expression_return retval = new SQLParser.expression_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		SQLParser.identifier_return identifier41 = default(SQLParser.identifier_return);
		SQLParser.constant_int_return constant_int42 = default(SQLParser.constant_int_return);
		SQLParser.constant_txt_return constant_txt43 = default(SQLParser.constant_txt_return);


		try { DebugEnterRule(GrammarFileName, "expression");
		DebugLocation(171, 4);
		try
		{
			// SQL.g:172:5: ( identifier | constant_int | constant_txt )
			int alt13=3;
			try { DebugEnterDecision(13, decisionCanBacktrack[13]);
			switch (input.LA(1))
			{
			case NonQuotedIdentifier:
				{
				alt13=1;
				}
				break;
			case MINUS:
			case Integer:
				{
				alt13=2;
				}
				break;
			case Txt:
				{
				alt13=3;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 13, 0, input);

					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(13); }
			switch (alt13)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:177:5: identifier
				{
				root_0 = (Expression)adaptor.Nil();

				DebugLocation(177, 5);
				PushFollow(Follow._identifier_in_expression834);
				identifier41=identifier();
				PopFollow();

				adaptor.AddChild(root_0, identifier41.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SQL.g:178:6: constant_int
				{
				root_0 = (Expression)adaptor.Nil();

				DebugLocation(178, 6);
				PushFollow(Follow._constant_int_in_expression841);
				constant_int42=constant_int();
				PopFollow();

				adaptor.AddChild(root_0, constant_int42.Tree);

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SQL.g:179:6: constant_txt
				{
				root_0 = (Expression)adaptor.Nil();

				DebugLocation(179, 6);
				PushFollow(Follow._constant_txt_in_expression849);
				constant_txt43=constant_txt();
				PopFollow();

				adaptor.AddChild(root_0, constant_txt43.Tree);

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("expression", 18);
			LeaveRule("expression", 18);
			Leave_expression();
		}
		DebugLocation(181, 4);
		} finally { DebugExitRule(GrammarFileName, "expression"); }
		return retval;

	}
	// $ANTLR end "expression"

	public class comparisonOperator_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_comparisonOperator();
	partial void Leave_comparisonOperator();

	// $ANTLR start "comparisonOperator"
	// SQL.g:183:1: comparisonOperator : ( Eq | Neq1 | Neq2 | Le1 | Le2 | Lt | Ge1 | Ge2 | Gt );
	[GrammarRule("comparisonOperator")]
	private SQLParser.comparisonOperator_return comparisonOperator()
	{
		Enter_comparisonOperator();
		EnterRule("comparisonOperator", 19);
		TraceIn("comparisonOperator", 19);
		SQLParser.comparisonOperator_return retval = new SQLParser.comparisonOperator_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken set44=null;

		Expression set44_tree=null;

		try { DebugEnterRule(GrammarFileName, "comparisonOperator");
		DebugLocation(183, 71);
		try
		{
			// SQL.g:183:20: ( Eq | Neq1 | Neq2 | Le1 | Le2 | Lt | Ge1 | Ge2 | Gt )
			DebugEnterAlt(1);
			// SQL.g:
			{
			root_0 = (Expression)adaptor.Nil();

			DebugLocation(183, 20);
			set44=(IToken)input.LT(1);
			if ((input.LA(1)>=Eq && input.LA(1)<=Gt))
			{
				input.Consume();
				adaptor.AddChild(root_0, (Expression)adaptor.Create(set44));
				state.errorRecovery=false;
			}
			else
			{
				MismatchedSetException mse = new MismatchedSetException(null,input);
				DebugRecognitionException(mse);
				throw mse;
			}


			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("comparisonOperator", 19);
			LeaveRule("comparisonOperator", 19);
			Leave_comparisonOperator();
		}
		DebugLocation(183, 71);
		} finally { DebugExitRule(GrammarFileName, "comparisonOperator"); }
		return retval;

	}
	// $ANTLR end "comparisonOperator"

	public class identifier_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_identifier();
	partial void Leave_identifier();

	// $ANTLR start "identifier"
	// SQL.g:216:1: identifier : NonQuotedIdentifier ->;
	[GrammarRule("identifier")]
	private SQLParser.identifier_return identifier()
	{
		Enter_identifier();
		EnterRule("identifier", 20);
		TraceIn("identifier", 20);
		SQLParser.identifier_return retval = new SQLParser.identifier_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken NonQuotedIdentifier45=null;

		Expression NonQuotedIdentifier45_tree=null;
		RewriteRuleITokenStream stream_NonQuotedIdentifier=new RewriteRuleITokenStream(adaptor,"token NonQuotedIdentifier");

		try { DebugEnterRule(GrammarFileName, "identifier");
		DebugLocation(216, 64);
		try
		{
			// SQL.g:217:2: ( NonQuotedIdentifier ->)
			DebugEnterAlt(1);
			// SQL.g:219:3: NonQuotedIdentifier
			{
			DebugLocation(219, 3);
			NonQuotedIdentifier45=(IToken)Match(input,NonQuotedIdentifier,Follow._NonQuotedIdentifier_in_identifier927);  
			stream_NonQuotedIdentifier.Add(NonQuotedIdentifier45);



			{
			// AST REWRITE
			// elements: 
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 219:23: ->
			{
				DebugLocation(219, 26);
				adaptor.AddChild(root_0, new Identifier(NonQuotedIdentifier45));

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("identifier", 20);
			LeaveRule("identifier", 20);
			Leave_identifier();
		}
		DebugLocation(219, 64);
		} finally { DebugExitRule(GrammarFileName, "identifier"); }
		return retval;

	}
	// $ANTLR end "identifier"

	public class constant_int_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_constant_int();
	partial void Leave_constant_int();

	// $ANTLR start "constant_int"
	// SQL.g:238:1: constant_int : ( MINUS )? Integer -> ^( TextNode ( MINUS )? Integer ) ;
	[GrammarRule("constant_int")]
	private SQLParser.constant_int_return constant_int()
	{
		Enter_constant_int();
		EnterRule("constant_int", 21);
		TraceIn("constant_int", 21);
		SQLParser.constant_int_return retval = new SQLParser.constant_int_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken MINUS46=null;
		IToken Integer47=null;

		Expression MINUS46_tree=null;
		Expression Integer47_tree=null;
		RewriteRuleITokenStream stream_MINUS=new RewriteRuleITokenStream(adaptor,"token MINUS");
		RewriteRuleITokenStream stream_Integer=new RewriteRuleITokenStream(adaptor,"token Integer");

		try { DebugEnterRule(GrammarFileName, "constant_int");
		DebugLocation(238, 58);
		try
		{
			// SQL.g:238:13: ( ( MINUS )? Integer -> ^( TextNode ( MINUS )? Integer ) )
			DebugEnterAlt(1);
			// SQL.g:238:15: ( MINUS )? Integer
			{
			DebugLocation(238, 15);
			// SQL.g:238:15: ( MINUS )?
			int alt14=2;
			try { DebugEnterSubRule(14);
			try { DebugEnterDecision(14, decisionCanBacktrack[14]);
			int LA14_0 = input.LA(1);

			if ((LA14_0==MINUS))
			{
				alt14=1;
			}
			} finally { DebugExitDecision(14); }
			switch (alt14)
			{
			case 1:
				DebugEnterAlt(1);
				// SQL.g:238:15: MINUS
				{
				DebugLocation(238, 15);
				MINUS46=(IToken)Match(input,MINUS,Follow._MINUS_in_constant_int944);  
				stream_MINUS.Add(MINUS46);


				}
				break;

			}
			} finally { DebugExitSubRule(14); }

			DebugLocation(238, 22);
			Integer47=(IToken)Match(input,Integer,Follow._Integer_in_constant_int947);  
			stream_Integer.Add(Integer47);



			{
			// AST REWRITE
			// elements: MINUS, Integer
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 238:30: -> ^( TextNode ( MINUS )? Integer )
			{
				DebugLocation(238, 33);
				// SQL.g:238:33: ^( TextNode ( MINUS )? Integer )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(238, 35);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(TextNode, "TextNode"), root_1);

				DebugLocation(238, 44);
				// SQL.g:238:44: ( MINUS )?
				if ( stream_MINUS.HasNext )
				{
					DebugLocation(238, 44);
					adaptor.AddChild(root_1, stream_MINUS.NextNode());

				}
				stream_MINUS.Reset();
				DebugLocation(238, 51);
				adaptor.AddChild(root_1, stream_Integer.NextNode());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("constant_int", 21);
			LeaveRule("constant_int", 21);
			Leave_constant_int();
		}
		DebugLocation(238, 58);
		} finally { DebugExitRule(GrammarFileName, "constant_int"); }
		return retval;

	}
	// $ANTLR end "constant_int"

	public class constant_txt_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<Expression>
	{
		private Expression _tree;
		public Expression Tree { get { return _tree; } set { _tree = value; } }  object IAstRuleReturnScope.Tree { get { return _tree; } }
	}

	partial void Enter_constant_txt();
	partial void Leave_constant_txt();

	// $ANTLR start "constant_txt"
	// SQL.g:239:1: constant_txt : Txt -> ^( TextNode Txt ) ;
	[GrammarRule("constant_txt")]
	private SQLParser.constant_txt_return constant_txt()
	{
		Enter_constant_txt();
		EnterRule("constant_txt", 22);
		TraceIn("constant_txt", 22);
		SQLParser.constant_txt_return retval = new SQLParser.constant_txt_return();
		retval.Start = (IToken)input.LT(1);

		Expression root_0 = null;

		IToken Txt48=null;

		Expression Txt48_tree=null;
		RewriteRuleITokenStream stream_Txt=new RewriteRuleITokenStream(adaptor,"token Txt");

		try { DebugEnterRule(GrammarFileName, "constant_txt");
		DebugLocation(239, 24);
		try
		{
			// SQL.g:240:2: ( Txt -> ^( TextNode Txt ) )
			DebugEnterAlt(1);
			// SQL.g:240:4: Txt
			{
			DebugLocation(240, 4);
			Txt48=(IToken)Match(input,Txt,Follow._Txt_in_constant_txt966);  
			stream_Txt.Add(Txt48);



			{
			// AST REWRITE
			// elements: Txt
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (Expression)adaptor.Nil();
			// 240:8: -> ^( TextNode Txt )
			{
				DebugLocation(240, 10);
				// SQL.g:240:10: ^( TextNode Txt )
				{
				Expression root_1 = (Expression)adaptor.Nil();
				DebugLocation(240, 12);
				root_1 = (Expression)adaptor.BecomeRoot((Expression)adaptor.Create(TextNode, "TextNode"), root_1);

				DebugLocation(240, 21);
				adaptor.AddChild(root_1, stream_Txt.NextNode());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (Expression)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (Expression)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("constant_txt", 22);
			LeaveRule("constant_txt", 22);
			Leave_constant_txt();
		}
		DebugLocation(240, 24);
		} finally { DebugExitRule(GrammarFileName, "constant_txt"); }
		return retval;

	}
	// $ANTLR end "constant_txt"
	#endregion Rules


	#region Follow sets
	private static class Follow
	{
		public static readonly BitSet _statements_in_start306 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _statement_in_statements315 = new BitSet(new ulong[]{0x14000000UL});
		public static readonly BitSet _SEMI_in_statements318 = new BitSet(new ulong[]{0x14000000UL});
		public static readonly BitSet _EOF_in_statements325 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _selectStatement_in_statement339 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _select_1_in_selectStatement355 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _select_in_select_1384 = new BitSet(new ulong[]{0x60000002UL});
		public static readonly BitSet _from_in_select_1386 = new BitSet(new ulong[]{0x40000002UL});
		public static readonly BitSet _where_in_select_1389 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _SELECT_in_select406 = new BitSet(new ulong[]{0x1C00018000UL});
		public static readonly BitSet _columns_in_select409 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _FROM_in_from429 = new BitSet(new ulong[]{0x402000000UL});
		public static readonly BitSet _tables_in_from432 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _WHERE_in_where439 = new BitSet(new ulong[]{0x1E00418000UL});
		public static readonly BitSet _condition_in_where441 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _column_in_columns462 = new BitSet(new ulong[]{0x2000002UL});
		public static readonly BitSet _COMMA_in_columns466 = new BitSet(new ulong[]{0x1C00018000UL});
		public static readonly BitSet _column_in_columns468 = new BitSet(new ulong[]{0x2000002UL});
		public static readonly BitSet _MUL_in_column485 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _identifier_in_column501 = new BitSet(new ulong[]{0x8000000UL});
		public static readonly BitSet _DOT_in_column503 = new BitSet(new ulong[]{0x10000UL});
		public static readonly BitSet _MUL_in_column505 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _expressions_in_column528 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _table_in_tables554 = new BitSet(new ulong[]{0x2000002UL});
		public static readonly BitSet _tables_0_in_tables556 = new BitSet(new ulong[]{0x2000002UL});
		public static readonly BitSet _COMMA_in_tables_0564 = new BitSet(new ulong[]{0x400000000UL});
		public static readonly BitSet _table_in_tables_0566 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _identifier_in_table591 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _subCondition_in_condition625 = new BitSet(new ulong[]{0x180000002UL});
		public static readonly BitSet _AND_in_condition629 = new BitSet(new ulong[]{0x1E00418000UL});
		public static readonly BitSet _OR_in_condition635 = new BitSet(new ulong[]{0x1E00418000UL});
		public static readonly BitSet _subCondition_in_condition640 = new BitSet(new ulong[]{0x180000002UL});
		public static readonly BitSet _NOT_in_subCondition652 = new BitSet(new ulong[]{0x1E00418000UL});
		public static readonly BitSet _LPAREN_in_subCondition663 = new BitSet(new ulong[]{0x1E00418000UL});
		public static readonly BitSet _condition_in_subCondition665 = new BitSet(new ulong[]{0x800000UL});
		public static readonly BitSet _RPAREN_in_subCondition667 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _predicate_in_subCondition678 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _expressions_in_predicate740 = new BitSet(new ulong[]{0x1FF0UL});
		public static readonly BitSet _comparisonOperator_in_predicate743 = new BitSet(new ulong[]{0x1C00018000UL});
		public static readonly BitSet _expressions_in_predicate746 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _expression_in_expressions792 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _identifier_in_expression834 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _constant_int_in_expression841 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _constant_txt_in_expression849 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _set_in_comparisonOperator0 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _NonQuotedIdentifier_in_identifier927 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _MINUS_in_constant_int944 = new BitSet(new ulong[]{0x800000000UL});
		public static readonly BitSet _Integer_in_constant_int947 = new BitSet(new ulong[]{0x2UL});
		public static readonly BitSet _Txt_in_constant_txt966 = new BitSet(new ulong[]{0x2UL});

	}
	#endregion Follow sets
}

} // namespace  Magic.Framework.OQL
